//
//  StatusCellBottomView.swift
//  Weibo10
//
//  Created by male on 15/10/18.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

/// 底部视图
class StatusCellBottomView: UIView {
    
    // MARK: - 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - 懒加载控件
    /// 转发按钮
    private lazy var retweetButton: UIButton = UIButton(title: "转发", color: UIColor.lightGrayColor(), imageName: "timeline_icon_retweet", fontsize: 12)
    /// 评论按钮
    private lazy var commentButton: UIButton = UIButton(title: "评论", color: UIColor.lightGrayColor(), imageName: "timeline_icon_comment", fontsize: 12)
    /// 点赞按钮
    private lazy var likeButton: UIButton = UIButton(title: "赞", color: UIColor.lightGrayColor(), imageName: "timeline_icon_unlike", fontsize: 12)
    
    //MARK: - 设置界面
    private func setupUI() {
        // 0. 背景图片
        backgroundColor = UIColor(white: 0.97, alpha: 1.0)
        
        // 1,添加控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(likeButton)
        // 分割线视图
        let sepWidth = 0.5
        let sepScale = 0.4
        let sep1 = sepView()
        let sep2 = sepView()
        addSubview(sep1)
        addSubview(sep2)

        // 2,设置布局
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
        sep1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.width.equalTo(sepWidth)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(sepScale)
        }
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetButton.snp_top)
            make.left.equalTo(sep1.snp_right)
            make.bottom.equalTo(retweetButton.snp_bottom)
            make.width.equalTo(retweetButton.snp_width)
        }
        sep2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(sepWidth)
            make.centerY.equalTo(commentButton.snp_centerY)
            make.height.equalTo(commentButton.snp_height).multipliedBy(sepScale)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton.snp_top)
            make.left.equalTo(sep2.snp_right)
            make.bottom.equalTo(commentButton.snp_bottom)
            make.right.equalTo(self.snp_right)
            make.width.equalTo(commentButton.snp_width)
        }
        
    }
    // 设置button之间的分割线视图,此处不用计算型属性有利于增加程序的可读性
    private func sepView() ->UIView {
        let view = UIView()
        view.backgroundColor = UIColor.greenColor()
        return view
    }

}
